import { createRouter, createWebHistory } from 'vue-router';
import menu from './menu';

const base = import.meta.env.BASE_URL;

const routes = [
  {
    path: '/welcome',
    name: 'welcome',
    component: () => import('@/pages/welcome.vue'),
  },
  ...menu.user,
  ...menu.pile,
  ...menu.channel,
  ...menu.enterprise,
  ...menu.config,
  ...menu.market,
  ...menu.financial,
  ...menu.auth,
  ...menu.statistical,
  ...menu.alarm,
  ...menu.docking,
  ...menu.logview,
];

const router = createRouter({
  history: createWebHistory(base),
  routes: [
    {
      path: '/',
      component: () => import('@/pages/login.vue'),
    },
    {
      path: '/',
      component: () => import('@/pages/main/main.vue'),
      children: routes,
    },
    {
      path: '/overView',
      name: 'overView',
      component: () => import('@/pages/overView/overView.vue'),
    },
    {
      path: '/overViewGtxny',
      name: 'overViewGtxny',
      component: () => import('@/pages/overViewGtxny/overViewGtxny.vue'),
    },
    {
      path: '/overViewStation',
      name: 'overViewStation',
      component: () => import('@/pages/overViewStation/overViewStation.vue'),
    },
    {
      path: '/:pathMatch(.*)',
      component: () => import('@/pages/error.vue'),
    },
  ],
});

export default router;
